﻿<UserControl x:Class="NicoView.View.NicoViewBroadcastSelectedControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:converter="clr-namespace:NicoView.View.Converter"
             xmlns:local="clr-namespace:NicoView.View"
             x:Name="SelectedControl"
             mc:Ignorable="d" 
            
             d:DesignHeight="500" d:DesignWidth="480">
    
    <UserControl.Resources>
        <converter:PrimaryCategoryConverter x:Key="primaryCategoryConverter"/>
        <converter:LivePublicStatusIsCommunityOnlyConverter x:Key="publicStatusIsCommunityConverter"/>

        <Style TargetType="{x:Type TextBlock}" x:Key="attentionStyle" >
            <Setter Property="Visibility" Value="Collapsed"/>
            <Setter Property="Foreground" Value="Red"/>
            <Setter Property="VerticalAlignment" Value="Center"/>

        </Style>

        <Style BasedOn="{StaticResource attentionStyle}" TargetType="{x:Type TextBlock}" x:Key="stringLengthAttentionStyle">
            <Style.Triggers>
                <DataTrigger Binding="{Binding}" Value="0">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>


        <Style BasedOn="{StaticResource attentionStyle}" TargetType="{x:Type TextBlock}" x:Key="nullAttentionStyle">
            <Style.Triggers>
                <DataTrigger Binding="{Binding}" Value="{x:Null}">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>

    </UserControl.Resources>
    
    <Grid>
        <Grid.RowDefinitions>

            <RowDefinition  Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>

        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="20"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>

        </Grid.ColumnDefinitions>
        
        <!-- タイトル行 -->
        <Label Grid.Row="0" Grid.Column="0" Content="{Binding Title, Mode=OneWay, Source={StaticResource resources}}"/>

        <TextBox x:Name="TitleEdit"    Margin="1"  Grid.Row="0" Grid.Column="2"  HorizontalScrollBarVisibility="Hidden"    Text="{Binding Title,UpdateSourceTrigger=PropertyChanged}" MaxWidth="{Binding ActualWidth, ElementName=CommunitySelect, Mode=OneWay}" DataContextChanged="TitleEdit_DataContextChanged" Loaded="TitleEdit_Loaded" />


        <TextBlock Grid.Row="0" DataContext="{Binding Title.Length}" Style="{StaticResource stringLengthAttentionStyle}" Grid.Column="3" VerticalAlignment="Center" Text="{Binding BroadcastingNoneTitleAttention, Mode=OneWay, Source={StaticResource resources}}"  />
        

        <!-- 詳細行 -->
        <Label Grid.Row="1"   Grid.Column="0" Content="{Binding Description, Mode=OneWay, Source={StaticResource resources}}"/>
        <TextBox Grid.Row="1"  Margin="1" Grid.Column="2"  AcceptsReturn="True"  HorizontalScrollBarVisibility="Auto"  VerticalScrollBarVisibility="Auto" Text="{Binding Description,UpdateSourceTrigger=PropertyChanged}"/>
        <TextBlock Grid.Row="1" Grid.Column="3" DataContext="{Binding Description.Length}" Style="{StaticResource stringLengthAttentionStyle}"   Text="{Binding BroadcastingNoneDescriptionAttention, Mode=OneWay, Source={StaticResource resources}}"  />
        
        
        <!-- コミュニティ選択行 -->
        <Label Grid.Row="2" Grid.Column="0" Content="{Binding BroadcastCommunity, Mode=OneWay, Source={StaticResource resources}}" />
        <ComboBox x:Name="CommunitySelect" IsSynchronizedWithCurrentItem="True" Grid.Row="2" Margin="1" Grid.Column="2" ItemsSource="{Binding CommunityInfos}"  SelectedItem="{Binding CurrentCommunityInfo}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock>
                        <Run Text="["/>
                        <Run Text="{Binding CommunityId,Mode=OneWay}"/>
                        <Run Text="]"/>
                        <Run Text="{Binding Description,Mode=OneWay}"/>
                        
                    </TextBlock>
                </DataTemplate>
            </ComboBox.ItemTemplate>

        </ComboBox>
        <TextBlock Grid.Row="2" Grid.Column="3" DataContext="{Binding CurrentCommunityInfo}" Style="{StaticResource nullAttentionStyle}"   Text="{Binding BroadcastingNoneCommunityAttention, Mode=OneWay, Source={StaticResource resources}}"  />
        
        <!-- カテゴリ行 -->
        <Label Grid.Row="3" Grid.Column="0" Content="{Binding Category, Mode=OneWay, Source={StaticResource resources}}" />
        <ComboBox Margin="1" Grid.Row="3" IsSynchronizedWithCurrentItem="True" Grid.Column="2" ItemsSource="{Binding PrimaryCategorys}" SelectedItem="{Binding PrimaryCategory}"  >
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={StaticResource primaryCategoryConverter}}"/>
                </DataTemplate>
            </ComboBox.ItemTemplate>

        </ComboBox>
        <TextBlock Grid.Row="3" Grid.Column="3" DataContext="{Binding PrimaryCategory}" Style="{StaticResource nullAttentionStyle}"   Text="{Binding BroadcastingNonePrimaryCategoryAttention, Mode=OneWay, Source={StaticResource resources}}"  />
        <!-- タグ行 -->
        <Label Grid.Row="4" Grid.Column="0" Content="{Binding Tag, Mode=OneWay, Source={StaticResource resources}}" />
        <local:NicoViewNiconicoTagEditControl Grid.Row="4" BorderThickness="0" Grid.Column="2" />
        
        <!-- 追加カテゴリ行 -->
        <Label Grid.Row="5" Grid.Column="0" Content="{Binding AddCategory, Mode=OneWay, Source={StaticResource resources}}" />
        <Grid Grid.Row="5" Grid.Column="2" VerticalAlignment="Center">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>

            <CheckBox Grid.Row="0" IsChecked="{Binding OutFace}" Content="{Binding OutFace, Mode=OneWay, Source={StaticResource resources}}" />
            <CheckBox Grid.Row="1" IsChecked="{Binding CruiseWait}" Content="{Binding CruiseWait, Mode=OneWay, Source={StaticResource resources}}"/>
            <CheckBox Grid.Row="2" IsChecked="{Binding AssaultWait}" Content="{Binding AssaultWait, Mode=OneWay, Source={StaticResource resources}}"/>
        </Grid>
        
        <!-- 放送公開範囲行 -->
        <Label Grid.Row="6" Grid.Column="0" Content="{Binding BroadcastPublicStatus, Mode=OneWay, Source={StaticResource resources}}" />
        <CheckBox VerticalAlignment="Center" Grid.Row="6" Grid.Column="2" IsChecked="{Binding PublicStatus,Converter={StaticResource publicStatusIsCommunityConverter}}" Content="{Binding BroadcastIsCommunityOnly,Mode=OneWay,Source={StaticResource resources}}"  />
        
        <!-- タイムシフト行 -->
        <Label Grid.Row="7" Grid.Column="0" Content="{Binding TimeShift, Mode=OneWay, Source={StaticResource resources}}" />
        <CheckBox Grid.Row="7" Grid.Column="2" IsChecked="{Binding TimeShiftEnabled}" VerticalAlignment="Center" Content="{Binding UsingMessage, Mode=OneWay, Source={StaticResource resources}}" />
        
        <!-- ツイッター行 -->
        <Label Grid.Row="8" Grid.Column="0"  Content="{Binding Twitter, Mode=OneWay, Source={StaticResource resources}}" />
        <Grid Grid.Row="8" Grid.Column="2" VerticalAlignment="Center" >
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <CheckBox Grid.Row="0" IsChecked="{Binding TwitterEnabled}" Content="{Binding UsingMessage, Mode=OneWay, Source={StaticResource resources}}"/>
            <Label Grid.Row="1" Grid.Column="0" Content="{Binding HashTag, Mode=OneWay, Source={StaticResource resources}}" />
            <TextBox Grid.Row="1" Margin="1"  Grid.Column="1" Text="{Binding TwitterTag}" />
            
        </Grid>
        
    </Grid>
</UserControl>
